home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / asmutil / asm_n_z.zip / PARSE.DOC < prev    next >
Text File  |  1986-01-19  |  3KB  |  76 lines

  1. PARSE.DOC
  2.  
  3. INTRODUCTION
  4.  
  5. The ability to use the command line allows a program to be used in batch
  6. files without  the use ofmenus and the required human intervention.
  7. PARSE.ASM will give an assembly language program the ability to use the
  8. command line.
  9.  
  10. BACKGROUND
  11.  
  12. When DOS loads a program to be executed, it builds a Program Segment Prefix
  13. (PSP).  DOS stores everything that was entered after the name of the program
  14. up to the Carriage Return in an area of the PSP starting at location 81
  15. hex(h).  While the maximum length of the command line is 127 (79h), the
  16. actual length of the entered string is stored as a binary number at location
  17. 80h.  Redirection parameters (e.g. <INPUT or >OUTPUT) are not included.
  18. This area is also the default Data Transfer Area (DTA).  This means that the
  19. command line information will be overwritten and lost if I/O is performed
  20. using File Control Blocks (FCB) and the DTA has not been moved.  While the
  21. area should be safe if the extended file management functions (3ch to 46h)
  22. are used, the author has discovered that functions 4eh and 4fh (Find First
  23. and Find Next) do use the area.   PARSE has several other advantages also.
  24.  
  25. WHAT PARSE DOES
  26.  
  27. PARSE performs the following tasks in the following order:
  28.     - Determines if there are any command line arguments (if none, MENU is
  29.       called.)
  30.     - Moves the entire command line onto the stack.
  31.     - Converts all blanks (ASCII 32) and below into null byte (all zeros
  32.       bits).
  33.     - Places the offset to the 1st byte of each command line argument
  34.       onto the stack.
  35.     - Places the total number of arguments onto the stack.
  36.     - Calls CMDLN
  37.     
  38. On entry to CMDLN and assuming a standard entry logic of "push bp" and "mov
  39. bp,sp", the stack is arranged thusly:
  40.     offset from SP => 0/1 value of BP 
  41.               2/3 return address 
  42.               4/5 number of arguments 
  43.               6/7 address of 1st argument 
  44.               8/9 address of 2nd argument etc.
  45. Thus, [bp-4] can be treated as argc in the "c" language, and [bp-6] can be
  46. treated as the first pointer in an array of pointers, similiar to argv in
  47. the "c" language.  The length of argv is argc words.  The actual command
  48. line arguments start right after the last element of argv.  The BP register
  49. now allows all the command line information to be available to the program.
  50.  
  51. OTHER FEATURES
  52.  
  53. PARSE is also a template for a program in the .COM file format.  The most
  54. important feature the GROUP pseudo-op which will collect the segments under
  55. one name so they all reside within a 64K physsical segment.  Using this
  56. pseudo-op removes the disadvantage of combining the data and code into one
  57. segment.
  58.  
  59. A comment field is set up between the two astericks.  Equate and macro files
  60. will be included but neither will appear in the .LST file.
  61.  
  62. COMMENTS
  63.  
  64. This code is released into the public domain without any restrictions as to
  65. its use.
  66.  
  67. The author has taken due care in writing this code, and the code is supplied
  68. as is.  The author makes no expressed or implied warranty of any kind with
  69. regard to this code.  In no event shall the author be liable for incidental
  70. or conseqential damages in connection with or arising out of the use of this
  71. code.
  72.  
  73. The author encourages comments.  Please leave comments, or suggestions in a
  74. message on Andy Smith's RBBS (301)-956-3396.
  75.  
  76. 19 Jan 85                            Raymond Moon